/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package alcatelparser.modules;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

/**
 *
 * @author geniuz
 */
public class ResultTagProperties
{

    private ResultTagProperties()
    {
        loadTagProperties();
    }

    private void loadTagProperties()
    {
        _props = new Properties();
        try
        {
            File file = new File(getResultTagPath(true));
            if(file.exists())
                _props.load(new FileInputStream(file));
            else
                _props.load(new FileInputStream(getResultTagPath(false)));
        }
        catch(IOException ioexception)
        {
            //throw new ApplicationInitalyzeError(I.I(981));
        }
    }

    public final void loadDefault()
    {
        try
        {
            _props.load(new FileInputStream(getResultTagPath(false)));
        }
        catch(IOException ioexception)
        {
            //LOG.error(ioexception);
        }
    }

    public static final ResultTagProperties getTagProperties()
    {
        if(_tProps == null)
            try
            {
                _tProps = new ResultTagProperties();
            }
            catch(Exception applicationinitalyzeerror)
            {
                //LOG.error(applicationinitalyzeerror);
            }
        return _tProps;
    }

    public static final void initialyze()
    {
        _tProps = new ResultTagProperties();
    }

    public final String getProperty(String s)
    {
        return _props.getProperty(s);
    }

    public final void setProperty(String s, String s1)
    {
        _props.put(s, s1);
    }

    public final void storeProperties()
    {
        try
        {
            _props.store(new FileOutputStream(getResultTagPath(true)), I.I(958));
        }
        catch(IOException ioexception)
        {
            //LOG.error(ioexception);
        }
    }

    private String getResultTagPath(boolean flag)
    {
        String s = flag ? I.I(616) : "";
        return (new StringBuilder()).append(Env.getEnv().getRunDir()).append(File.separator).append(s).append(I.I(941)).toString();
    }

    private static final String RESULT_PROPERTIES_PATH = "resulttags.props";
    private Properties _props;
    private static ResultTagProperties _tProps;
    //private static final Logger LOG = Logger.getLogger(com/alcatel/properties/ResultTagProperties);

}
